<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台</title>

    <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
</head>

<body>

<include file="Common/topNav" />

<div class="container-fluid">
    <div class="row">
        <include file="Common/leftMenu" />
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="cont-title clearfix">
                <div class="title">人员管理 - {$teamInfo.team_name}</div>
                <div class="btn-group">
                    <button class="btn" type="button" userId="" teamId="{$teamId}" id="addTeamUser">添加</button>
                    <button type="button" onclick="javascript:window.history.back();" class="btn btn2">返回</button>
                </div>
            </div>
            
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="tableData">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>职位</th>
                        <th>手机号</th>
                        <th>邮箱</th>
                        <th>角色</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="list['list']" id="lt">
                        <tr>
                            <td>{$lt.real_name}</td>
                            <td>{$lt.position}</td>
                            <td>{$lt.mobile}</td>
                            <td>{$lt.email}</td>
                            <td>{$lt.role.name|default="-"}</td>
                            <td>{$lt.status}</td>
                           
                            <td>
                                <a href="javascript:void(0);" teamId="{$lt.team_id}" userId="{$lt.id}" class="edit">查看</a>
                                | <a href="javascript:void(0);" teamId="{$lt.team_id}" userId="{$lt.id}" class="delete">删除</a>
                                | <a href="javascript:void(0);" teamId="{$lt.team_id}" userId="{$lt.id}" class="unTeamUser">禁用</a>
                            </td>
                        </tr>
                        
                    </volist>
                        
                    </tbody>
                </table>
                <div class="page">
                    {$list.page}
                </div>
            </div>
        </div>
    </div>
</div>


<include file="Common/modalHtmls" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
<script type="text/javascript">
    $("#addTeamUser,#tableData .edit").click(function () {
        var teamId = $(this).attr("teamId");
        var userId = $(this).attr("userId");
        common.htmlAjax("{:U('Admin/Space/Settled/teamUserDetail')}", { teamId : teamId , userId : userId }, function (html) {
            if(common.isJsonString(html)){
                var error = JSON.parse(html);
                if (error.info){
                    common.alert("提示",error.info);
                }
                return;
            }
            $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
        })
    })
    
    
    $("#tableData .unTeamUser").click(function(){
        var userId = $(this).attr("userId");
        common.confirm("提示", "确定要禁用当前用户?", function () {
            common.ajax("{:U('Admin/Space/Settled/unTeamUser')}", {userId : userId}, function (data) {
                //console.log(data);
                if (data == true) {
                    common.alert("提示", "当前用户禁用成功!", function () {
                        common.reload();
                    });
                } else if (data.info){
                    common.alert("提示",data.info);
                }

            });
        });
    })
    
    $("#tableData .delete").click(function(){
        var userId = $(this).attr("userId");
        common.confirm("提示", "确定要删除当前用户?", function () {
            common.ajax("{:U('Admin/Space/Settled/deleteTeamUser')}", {userId : userId}, function (data) {
                //console.log(data);
                if (data == true) {
                    common.alert("提示", "删除当前用户成功!", function () {
                        common.reload();
                    });
                } else if (data.info){
                    common.alert("提示",data.info);
                }

            });
        });
    })
</script>
</body>
</html>
